package com.core.banner;

import android.content.Context;
import android.view.View;

import com.bigkoo.convenientbanner.holder.Holder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.core.R;

import androidx.appcompat.widget.AppCompatImageView;

/**
 * Created by ywm
 */

public class ImageHolder extends Holder<String> {


    private static final RequestOptions BANNER_OPTIONS = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate()
            .centerCrop();

    private AppCompatImageView ivPost;
    private Context context;

    public ImageHolder(View itemView, Context context) {
        super(itemView);
        this.context = context;
    }

    @Override
    protected void initView(View itemView) {
        ivPost = itemView.findViewById(R.id.ivPost);
    }

    @Override
    public void updateUI(String data) {
        Glide.with(context)
                .load(data)
                // .apply(BANNER_OPTIONS)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .centerCrop()
                .into(ivPost);
    }
}
